﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace IM.Easy.Core.Cache
{
    /// <summary>
    /// 缓存接口
    /// </summary>
    public interface ICache
    {
        void Set(string key, object value, TimeSpan? absoluteExpirationRelativeToNow = null);
        T Get<T>(string key);
        void Remove(string key);

        /// <summary>
        /// 通过正则匹配删除
        /// </summary>
        /// <param name="keyPattern"></param>
        void RemoveByPattern(string keyPattern);

        /// <summary>
        /// 检查缓存项是否存在
        /// </summary>
        bool Exists(string key);

        /// <summary>
        /// 清空所有缓存项
        /// </summary>
        void Clear();

        /// <summary>
        /// 获取所有缓存列表
        /// </summary>
        /// <returns></returns>
        IDictionary<string, string> GetAll();
    }
}
